<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>展览《${exhibition.title}》详情</title>
<link href="../style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script src="../js/artDialog.js?skin=gray"></script>
<script src="../js/artDialog.iframeTools.js"></script>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
<script language="javascript" type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript">

$(function(){

	$("#exhibitionLink").click(function(){
		art.dialog.open('${ctx}/fileUpload!uploadPrepare.do?imgType=exhibition&sharpId=7',{title:'修改展览海报图片',width:800,height:550},false);
    });

    $("#addPaintingImage").click(function(){
    	art.dialog.open('${ctx }/painting/addPrepareByExhibition.do?exhibition_Id=${exhibition.id}',{title:'为展览添加作品',width:820,height:550,lock:true},false);
    });

    $("a[name='modifyHref']").click(function(){
		var id = $(this).attr("title");
		art.dialog.open('${ctx}/painting/modifyPrepare.do?painting.id='+id,{title:'修改作品',width:820,height:550,lock:true},false);
    });

    m2('m1_005','m1_005_03');

    var city_id = '${exhibition.cityInfo.id}';
    checkCity(city_id);
	
});

/******改变作品上传状态 *****/
function changeState(id,status){
	if(status == '2'){
		if (window.confirm("确认删除此作品？")) {
			$.ajax( {
				type : "POST",
				url : "${ctx}/painting/changeUploadState.do?painting.id="+id+"&operateStr="+status,
				timeout : 6000,
				async : false, //ajax同步
				success : function(data, textStatus) {
					if(data == '0000'){
						window.location.reload(true);
					}
				}
			});
		}
	}else{
		$.ajax( {
			type : "POST",
			url : "${ctx}/painting/changeUploadState.do?painting.id="+id+"&operateStr="+status,
			timeout : 6000,
			async : false, //ajax同步
			success : function(data, textStatus) {
				if(data == '0000'){
					window.location.reload(true);
				}
			}
		});
	}
}

function checkForm(){

	var title = $.trim($("#title").val());
	if( title  ==  ""){
		$("#title").focus();
		 alert("请填写展览主题。");
		 return false;
	}

	var description = $.trim($("#description").val());
	if( description  ==  ""){
		$("#description").focus();
		 alert("请填写序言。");
		 return false;
	}

	var picImage = $("#picImage").val();
	if( picImage == "" ){
		alert("请上传展览海报图片");
		return false;
	}

	var province = $("#provinceInfoSelect").val();
	if( province == ""){
		 alert("请选择展览所在省。");
		 return false;
	}

	var city = $("#cityInfoSelect").val();
	if( city == ""){
		 alert("请选择展览所在市。");
		 return false;
	}

	var beginTime = $.trim($("#beginTime").val());
	if( beginTime  ==  ""){
		 alert("请填写展览开始时间。");
		 return false;
	}

	var endTime = $.trim($("#endTime").val());
	if( endTime  ==  ""){
		 alert("请填写展览结束时间。");
		 return false;
	}

	if(window.confirm("确认修改？")){
		$.ajax({
			type:'POST',
			url:'${ctx }/exhibition/modify.do',
			async : false, //ajax同步
			data:$("#exhibitionForm").serialize(),//序列化表单里所有的内容
			success: function(data){
			  if(data =='0000'){
	    			alert("展览基本信息保存成功！");
	    			var win = art.dialog.open.origin;//来源页面
					// 如果父页面重载或者关闭其子对话框全部会关闭
					win.location.reload();
					return false;
				}else{
					alert("展览基本信息保存失败！");
					return false;
				}
			}
		});
	}
}
</script>	
</head>

<body>
<!-- 页面头部  -->
<jsp:include page="/commons/head_member.jsp"></jsp:include>

<form action="${ctx }/exhibition/modify.do" method="post" id="exhibitionForm" name="exhibitionForm">
<table align="center" width="960" border="0" cellspacing="0" cellpadding="0" class="tbl_border_top"  bgcolor="#ffffff">
        <tr>
         	<td>&nbsp;</td>
             <td align="center" class="bt14A">${exhibition.title }简介</td>
         </tr>
         <tr>
           <td class="bt14A" align="right"><span class="style15">*</span> 展览主题：</td>
           <td class="bt14A" align="left">
              <input name="exhibition.title" type="text" size="30" id="title" value="${exhibition.title }" maxlength="50">
           </td>
           <td width="198" rowspan="8" class="bt14A" align="center" valign="top">
              <table width="165" height="217" border="0" cellpadding="0" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#CCCCCC">
                <tr>
                  <td bgcolor="#FFFFFF">
                   	<div id="photoTd" style="width: 165px;height: 220px;vertical-align: middle;text-align: center;overflow: hidden;">
            			<img width="165" height="220" src="${exhibition.imagepath}">
            		</div>
                  </td>
                </tr>
              </table>
           </td>
         </tr>
         <tr>
           <td class="bt14A"  align="right"><span class="style15">*</span> 序言：</td>
           <td class="bt14A" align="left"><textarea name="exhibition.description" cols="64" rows="5" id="description">${exhibition.description }</textarea>
           </td>
           <td></td>
         </tr>
         <tr>
           <td class="bt14A" align="right"><span class="style15">*</span>展览海报：</td>
           <td class="bt14A"><span class="style18"><a id="exhibitionLink" style="cursor: pointer;color: red">上传</a></span></td>
         </tr>
         <tr>
           <td class="bt14A" align="right"><span class="style15">*</span> 参展艺术家：</td>
           <td class="bt14A">
           	 <input name="exhibition.artists" type="text" size="30" id="artists" value="${exhibition.artists }" maxlength="100">
             <span class="style19">多人请用，号分隔</span>
           </td>
         </tr>
	      <tr>
              	<td class="bt14A" align="right"><span class="style15">* </span>所在地：</td>
              	<td class="bt14A">
                	<select name="exhibition.provinceInfo.id" id="provinceInfoSelect" onchange="changeProvince()">
                      <option value="">选择省份</option>
                      <c:forEach items="${provinceInfoList}" var="provinceInfo" varStatus="status">
		            		<option value="${ provinceInfo.id}" <c:if test="${exhibition.provinceInfo.id == provinceInfo.id }">selected="selected"</c:if>/> ${ provinceInfo.name}</option>
		        	  </c:forEach>
                    </select>
                    <select name="exhibition.cityInfo.id" id="cityInfoSelect">
                      <option value="">选择县市</option>
                    </select>
              	</td>
	          </tr>
	          <tr>
		            <td class="bt14A" align="right"><span class="style15">*</span>展览地点：</td>
		            <td class="bt14A"><input name="exhibition.address" type="text" size="40" id="address" value="${exhibition.address }"  maxlength="200"></td>
	          </tr>
	          <tr>
		            <td class="bt14A" align="right"><span class="style15">*</span>展览时间：</td>
		            <td class="bt14A">
		            	<input name="exhibition.beginTime" value="<fmt:formatDate value='${exhibition.beginTime }' pattern='yyyy-MM-dd'/>" type="text" size="15" id="beginTime"  onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})">开始至
	               		<input name="exhibition.endTime"   value="<fmt:formatDate value='${exhibition.endTime }' pattern='yyyy-MM-dd'/>"  type="text" size="15" id="endTime" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})">结束
		            </td>
	          </tr>
         <tr>
           <td class="bt14A" align="right">策展人或单位：</td>
           <td class="bt14A">
               <input name="exhibition.publisher" type="text" size="30" id="publisher" value="${exhibition.publisher }">
          	  <!-- 隐藏域 begin -->
     			<input name="exhibition.imageInfo.id" type="hidden"  id="picImage" value="${exhibition.imageInfo.id }">
     			<input name="exhibition.id" type="hidden"  value="${exhibition.id }">
     			<input name="exhibition.totalCount" type="hidden"  value="${exhibition.totalCount }">
     			<input name="exhibition.unit" type="hidden"  value="${exhibition.unit }">
     			<input name="exhibition.type" type="hidden"  value="${exhibition.type }">
     	 	  <!-- 隐藏域 end -->
           </td>
         </tr>
         <tr>
            <td width="148"> </td>
          <td class="nw12a">
           	<img src="../images/an24b.gif" width="106" height="31" onClick="javascript:checkForm()" style="cursor: pointer ;border: 0"></td>
         </tr>
     </table>

<table align="center" width="960" border="0" cellspacing="0" cellpadding="0"   class="tbl_add_border">
            <tr>
              <td style="padding: 5px 0px 5px 35px;"><img src="../images/an12.gif" width="106" height="31" id="addPaintingImage" style="cursor: pointer;"></td>
            </tr>
           <tr><td colspan="100%" align="left">
				<table cellpadding="0" cellspacing="0" border="0">
					 <c:forEach items="${exhibition.paintings}" var="result" varStatus="status">
			              <%@ include file="/member/painting_detail_fragment.jsp" %>
					</c:forEach>
				</table>
		</td></tr>
</table>
     
</form> 

<jsp:include page="/commons/foot_member.jsp"></jsp:include>

</body>
</html>